import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkDialectGamePage(Base):
    """
    车乐汇猜方言游戏页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.dialect_close_btn = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("iv_close"))

        # 猜歌名标题提示
        self.dialect_title_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_question"))

        # 歌曲提示
        self.dialect_tip_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_tip"))

        # 答案1
        self.dialect_answer_one_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_answer_a"))

        # 答案2
        self.dialect_answer_two_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_answer_b"))

        # 答案3
        self.dialect_answer_three_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_answer_c"))

        # 答案4
        self.dialect_answer_four_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_answer_d"))

        # 第几题
        self.dialect_questions_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_title"))

        # 暂停按钮
        self.dialect_stop_btn = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("iv_state"))

        # 答案提示
        self.dialect_answer_tip_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_answer_tip"))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.dialect_close_btn)

    def get_title(self):
        """
        获取回答题目标题

        :return:获取元素
        """
        return self.find_element_o(self.dialect_title_text)

    def get_tip(self):
        """
        获取猜方言提示

        :return:获取元素
        """
        return self.find_element_o(self.dialect_tip_text)

    def get_questions(self):
        """
        获取第几题文本

        :return:获取元素
        """
        return self.find_element_o(self.dialect_questions_text)

    def click_answer_one(self):
        """
         点击答案1按钮

         :return:None
         """
        self.click_element(self.dialect_answer_one_text)

    def click_answer_two(self):
        """
         点击答案2按钮

         :return:None
         """
        self.click_element(self.dialect_answer_two_text)

    def click_answer_three(self):
        """
         点击答案3按钮

         :return:None
         """
        self.click_element(self.dialect_answer_three_text)

    def click_answer_four(self):
        """
         点击答案4按钮

         :return:None
         """
        self.click_element(self.dialect_answer_four_text)

    def click_stop(self):
        """
         点击暂停按钮

         :return:None
         """
        self.click_element(self.dialect_stop_btn)

    def get_answer_tip(self):
        """
        获取答案提示

        :return:获取元素
        """
        return self.find_element_o(self.dialect_answer_tip_text)

    def is_display_carpark_game(self):
        """
        查看是否进入猜方言回答中页面

        :return:
        """
        return self.is_display(self.dialect_answer_tip_text)
